#  rm15dump v 1.0 - Downloads data from Geoscan Research RM15-D resitivity meters.
#  Copyright (C) 2010 John Donovan - mersey.viking@gmail.com
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.

if (MSVC)
  # Removes the bogus /machine:I386 switch, and sets the stack to its default size.
  set(CMAKE_EXE_LINKER_FLAGS "" CACHE TYPE INTERNAL FORCE)
  set(CMAKE_CXX_STACK_SIZE "" CACHE TYPE INTERNAL FORCE)
endif()

project(rm15dump)
cmake_minimum_required(VERSION 2.6)

set(CMAKE_VERBOSE_MAKEFILE ON)

set(Boost_USE_STATIC_LIBS   ON)
set(Boost_USE_MULTITHREADED ON)
find_package(Boost 1.37.0 COMPONENTS system)
find_package(GDAL)
find_package(Qt4 COMPONENTS QtCore REQUIRED)

if (UNIX)
  add_definitions(-Wall -O3)
#  add_definitions(-Wall -g)
endif()

if (MSVC)
  add_definitions(/D_CRT_SECURE_NO_DEPRECATE)
  add_definitions(/D_CRT_NONSTDC_NO_DEPRECATE)
  add_definitions(/D_WIN32_WINNT=0x0501)
  add_definitions(/D_USE_MATH_DEFINES)
  add_definitions(/DBOOST_DATE_TIME_NO_LIB)

  set(CMAKE_CXX_FLAGS "/nologo /W3 /FR /Oi /EHsc")
  set(CMAKE_CXX_FLAGS_DEBUG "/MDd /Od /ZI")
  set(CMAKE_CXX_FLAGS_RELEASE "/MD /Ox /GS-")
  set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MD /Ox /GS- /Z7")

  # Because there's no clearly-defined place for argtable2 to live on Windows machines, put your relevant paths here.
  set(ARGTABLE2_INCLUDE_DIR D:/projects/argtable2-12/src)
  set(ARGTABLE2_LIBRARY_DIR D:/projects/argtable2-12/src)

  include_directories(${ARGTABLE2_INCLUDE_DIR})
  link_directories(${ARGTABLE2_LIBRARY_DIR} ${Boost_LIBRARY_DIRS})
endif()

include_directories(${Boost_INCLUDE_DIRS} ${GDAL_INCLUDE_DIR})
include(${QT_USE_FILE})

add_executable(rm15dump src/main.cpp src/rm15d.cpp)

target_link_libraries(rm15dump argtable2 ${Boost_LIBRARIES} ${GDAL_LIBRARY} ${QT_LIBRARIES})
